<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加桌号</title>
    <#assign base=request.contextPath/>
    <#setting  number_format="0.##"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${base}/backstage/layui/css/layui.css" media="all">
    <script src="${base}/backstage/layui/layui.js?t=1"></script>
    <script src="${base}/backstage/js/jquery-1.8.3.min.js?t=1"></script>
    <script src="${base}/backstage/js/feng.js?t=1"></script>
    <script src="${base}/backstage/js/loading.js?t=1"></script>
</head>
<body>

<br>
<form class="layui-form " action="" style="padding-left: 15px;">


    <div class="layui-form-item">
        <label class="layui-form-label">桌号名称</label>
        <div class="layui-input-block">
            <input class="layui-input" name="name" id="name" placeholder="请输入桌号名称" autocomplete="off">
        </div>
    </div>


    <div align="center">
        <button type="button" class="layui-btn" id="saveButton">保存</button>
    </div>
    <br>
    <br>
</form>
<script>


    layui.use(['form', 'layer', 'upload','table'], function () {
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery
            , upload = layui.upload;
        var table = layui.table;
    })


    $("#saveButton").on("click", function () {


        if($("#name").val()==""){
            layer.msg("桌号名称不能为空")
            return
        }


        var formDate = {
            name:$("#name").val(),
        }

        $.ajax({
            type: "POST",
            contentType: "application/json;charset=UTF-8",
            url: "${base}/admin/tableNumber/saveOrUpdate",
            data: JSON.stringify(formDate),
            beforeSend: function () {
                loading("数据提交中，请稍后......");
            },
            success: function (data) {
                if (data.code === 200) {
                    layer.msg(data.msg)
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.selectName();
                        //  abc();
                    }, 500)
                } else {
                    layer.msg(data.msg)
                }
            }
        });
    })

</script>
<script>
    // function abc() {
    //     if ("WebSocket" in window) {
    //         ws = new WebSocket("ws://localhost:80/websocket/"+"admin");
    //         ws.onopen = function() {
    //             // alert("连接成功...");
    //         };
    //         //接收到消息的回调方法
    //         ws.onmessage = function (evt) {
    //             var msg = evt.data;
    //             if(msg==="refresh_index_order"){
    //                 selectName();
    //             }
    //
    //         };
    //         //监听窗口关闭事件，当窗口关闭时，主动去关闭websocket连接，防止连接还没断开就关闭窗口，server端会抛异常。
    //         window.onbeforeunload = function () {
    //             // alert("关闭窗口")
    //             ws.close();
    //         }
    //         //连接发生错误的回调方法
    //         ws.onerror = function () {
    //             alert("消息通道发生错误");
    //         };
    //         ws.onclose = function() {
    //             alert("连接已关闭...");
    //             ws.close();
    //         };
    //     } else {
    //         // 浏览器不支持 WebSocket
    //         alert("您的浏览器不支持 WebSocket!");
    //
    //     }
    // }




</script>


</body>
</html>